package com.ezbuy.common.functions;

/**
 * 拦截消费者,dest处理之后,src继续处理
 * ezbuy 2018/12/1 下午2:06
 */
public class InterceptConsumer<T> implements Consumer<T> {

    private final Consumer src;
    private final Consumer dest;

    public InterceptConsumer(Consumer src, Consumer dest) {
        this.src = src;
        this.dest = dest;
    }

    @Override
    public void consume(T response) {
        if (dest != null) {
            dest.consume(response);
        }
        src.consume(response);
    }
}
